<template>
  <div>
    <el-dialog title="初始化的菜单列表" :visible.sync="dialogTableVisible">
      <el-tag type="warning">请谨慎操作! 初始化菜单会覆盖之前记录!</el-tag>
      <el-tree
        style="margin: 20px 0"
        :data="data"
        :props="defaultProps"
        @node-click="handleNodeClick"
      ></el-tree>
      <el-button @click="cancle">取消</el-button>
      <el-button @click="save" type="primary">保存</el-button>
    </el-dialog>
  </div>
</template>

<script>
import menuApi from "@/api/authority/resource/index";

export default {
  components: {},

  data() {
    return {
      data: [],
      defaultProps: {
        children: "children",
        label: "title",
      },
      dialogTableVisible: false,
    };
  },

  created() {
    this.init();
  },

  mounted() {},

  methods: {
    save() {
      this.$emit("tofather");
      this.dialogTableVisible = !this.dialogTableVisible;
      menuApi.saveInitMenus
    },
    cancle() {
      this.dialogTableVisible = !this.dialogTableVisible;
    },
    handleNodeClick(data) {
      console.log(data);
    },
    init() {
      menuApi.getInitMenus().then((res) => {
        console.log(res);
        this.data = res.data.permissionList;
      });
    },
  },

  computed: {},

  watch: {},
};
</script>

<style scoped lang='scss'>
</style>